{% extends 'base_main.html' %}
{% block ext_css %}
    {{ super() }}
    <link rel="stylesheet" href="{{ url_for('static',filename='app/market/market.css',_external=True) }}">
{% endblock %}

{% block ext_js %}
    {{ super() }}
    <script type="text/javascript" src="{{ url_for('static',filename='app/market/js/market.js') }}"></script>
{% endblock %}
{% block content %}
    <div id="market">
        {#    左边大类型导航#}
        <aside>
            <ul>
                {% for foodtype in context.foodtypes %}
                    <li id="typeid_{{ foodtype.typeid }}">
                        <a href="{{ url_for( 'app.marketwithparas', typeid=foodtype.typeid, childcid='0', order='0') }}">{{ foodtype.typename }}</a>
                        {% if foodtype.typeid == context.typeid %}
                            <span class="yellowSlide"></span>
                        {% endif %}
                    </li>
                {% endfor %}
            </ul>
        </aside>

        <section>
            <nav>
                <ul>
                    <li id="all_types"><span>全部分类<span class="glyphicon glyphicon-chevron-down"
                                                       id="all_type_logo"></span></span></li>
                    {#                    js 中添加点击事件 #}
                    <li id="sort_rule"><span>综合排序<span class="glyphicon glyphicon-chevron-down"
                                                       id="sort_rule_logo"></span></span></li>
                    {#                        glyphicon glyphicon-chevron-up#}
                </ul>
            </nav>
            <menu>
                {{ csrf_token }}
                <ul>
                    {% for goods in context.goods_list %}
                        <li>
                            <a href="#">
                                <img src="{{ goods.productimg }}" alt="{{ goods.productlongname }}">
                                <div class="shoppingInfo">
                                    <h6>{{ goods.productlongname }}</h6>
                                    <p class="detailTag">
                                        <span>精选</span>
                                        <span>热销中</span>
                                    </p>
                                    <p class="unit">{{ goods.specifics }}</p>
                                    <p class="price">
                                        <span>{{ goods.price }}</span>
                                        <s>{{ goods.marketprice }}</s>
                                    </p>
                                </div>
                            </a>
                            <section>
                                <button goodsid="{{ goods.id }}" class="subShopping">-</button>
                                <span>
                                    {% for cart in context.carts %}
                                        {% if cart.goods_id==goods.id %}
                                            {{ cart.c_num }}
                                        {% else %}
                                        {% endif %}
                                    {% endfor %}
                                </span>
                                <button goodsid="{{ goods.id }}" class="addShopping">+</button>
                            </section>
                        </li>
                    {% endfor %}
                </ul>
                <div id='all_types_container'>
                    <div>
                        {% for childtypename in context.childtypenames %}
                            <a href="{{ url_for( 'app.marketwithparas', typeid=context.typeid, childcid=childtypename.1, order='0' ) }}">
                                {% if childtypename.1==context.childcid %}
                                    <button class="btn btn-primary">{{ childtypename.0 }}</button>
                                {% else %}
                                    <button class="btn btn-default">{{ childtypename.0 }}</button>
                                {% endif %}
                            </a>
                        {% endfor %}
                    </div>
                </div>

                <div id='sort_container'>
                    <div>
                        {% for order in context.order_list %}
                            <a href="{{ url_for( 'app.marketwithparas', typeid=context.typeid, childcid=context.childcid, order=order.1 ) }}">
                                {% if order.1 == context.order %}
                                    <button class="btn btn-primary">{{ order.0 }}</button>
                                {% else %}
                                    <button class="btn btn-default">{{ order.0 }}</button>
                                {% endif %}
                            </a>
                        {% endfor %}
                    </div>
                </div>
            </menu>
        </section>
    </div>
{% endblock %}